package app.entity;


import refactor.entity.User;
import lombok.Data;

import java.io.Serializable;

@Data
public class UserSession implements Serializable {

	private static final long serialVersionUID = -8815458540984728526L;

	private Integer id;// 用户在数据库中的主键
	private String realName;// 用户的真实姓名
	private String authorityInfo;// 授权信息
	private String email;// 电子邮件
	private String frozen;// 用户是否已经被冻结
	private String phoneNumber;// 手机
	private String password;// 密码
	private String qq;
	private String name;// 用户的登录名
	private String openId;// 微信id
	private String avatar;// 微信头像
	private Integer roleId;// 用户角色主键,在系统中为角色的子目录名称
	private String roleName;// 用户角色名称
    private Integer organizationId;//用户所属公司
    private Integer regionId;//用户所属地区
    
	public UserSession() {
	}

	public UserSession(Integer id, String realName, String authorityInfo,
					   String email, String frozen, String phoneNumber, String password,
					   String qq, String name, String openId, String avatar,
					   Integer roleId, String roleName, Integer organizationId, Integer regionId) {
		this.id = id;
		this.realName = realName;
		this.authorityInfo = authorityInfo;
		this.email = email;
		this.frozen = frozen;
		this.phoneNumber = phoneNumber;
		this.password = password;
		this.qq = qq;
		this.name = name;
		this.openId = openId;
		this.avatar = avatar;
		this.roleId = roleId;
		this.roleName = roleName;
		this.organizationId = organizationId;
		this.regionId = regionId;
	}

	public UserSession(User it) {
		this.id = it.getId();
		this.realName = it.getRealName();
		this.authorityInfo = it.getAuthorityInfo();
		this.email = it.getEmail();
		this.frozen = it.getFrozen();
		this.phoneNumber = it.getPhoneNumber();
		this.password = it.getPassword();
		this.qq = it.getQq();
		this.name = it.getName();
		this.openId = it.getOpenId();
		this.avatar = it.getAvatar();
		this.roleId = it.getRoleId();
		this.roleName = it.getRoleName();
		this.organizationId = it.getOrganizationId();
		this.regionId = it.getRegionId();
	}

	public User getUser() {
		User it = new User();
		it.setId(this.id);
		it.setRealName(this.realName);
		it.setAuthorityInfo(this.authorityInfo);
		it.setEmail(this.email);
		it.setFrozen(this.frozen);
		it.setPhoneNumber(this.phoneNumber);;
		it.setPassword(this.password);
		it.setQq(this.qq);
		it.setName(this.name);
		it.setOpenId(this.openId);
		it.setAvatar(this.avatar);
		it.setRoleId(this.roleId);
		it.setRoleName(this.roleName);
		it.setOrganizationId(this.organizationId);
		it.setRegionId(this.regionId);
		app.utils.Md5 md5 = new app.utils.Md5();
		it.setPasswordDigest(md5.getDigest(this.password));
		it.setNameDigest(md5.getDigest(this.name));

		return it;
	}
}
